#include "stdafx.h"
#include "unique_id.h"

time_t UniqueID::GlobalTime;
int UniqueID::GlobalSerialNumber;

bool UniqueID::operator ==(UniqueID& id)const
{
	return (Time == id.Time) && (SerialNumber == id.SerialNumber);
}

bool UniqueID::operator !=(UniqueID& id)const
{
	return (Time != id.Time) || (SerialNumber != id.SerialNumber);
}

void UniqueID::GenerateID()
{
	time(&Time);

	if(Time != GlobalTime)
		GlobalSerialNumber = 0;

	GlobalTime = Time;
	GlobalSerialNumber++;

	SerialNumber = GlobalSerialNumber ;
}

UniqueID::UniqueID()
{
	Time = 0;
	SerialNumber = 0;
}